<!-- 规则配置弹窗 -->
<template>
  <div @click.stop="()=>{}">
    <Dialogdrawerdefect
      :ddtvisible.sync="showRight"
      :size="dlgWidth"
      :has-modal="false"
      :modal-append-to-body="false"
      :modal="false"
      @close="handleClose">
      <div>
        <div class="temp_tit">{{curStatus === pageStatus.edit ? `编辑规则【${editName}】`:'新建规则'}}</div>
        <el-form class="rule-form" ref="form" :model="ruleForm" :rules="rules">
          <div class="rule_wrap" v-loading="saveLoading">
            <div class="rule_basebox">
              <!-- <el-form-item label="医院" label-width="90px" prop="hospitalCode">
                    <el-select size="small" v-model="ruleForm.hospitalCode" placeholder="请选择医院">
                      <el-option
                        v-for="item in mx_hospitalList"
                        :key="item.hospitalCode"
                        :label="item.hospitalName"
                        :value="item.hospitalCode"
                      ></el-option>
                    </el-select>
                  </el-form-item> -->
              <el-form-item label="规则名称:" prop="ruleName" label-width="84px" class="describe-input">
                <el-input size="small" v-model="ruleForm.ruleName" clearable placeholder="请输入"></el-input>
              </el-form-item>
              <el-form-item label="规则描述:" prop="ruleDescribe" label-width="84px" class="describe-input">
                <el-input size="small" v-model="ruleForm.ruleDescribe" clearable placeholder="请输入"></el-input>
              </el-form-item>
              <el-form-item label="规则提醒:" prop="ruleMessage" label-width="84px" class="describe-input">
                <el-input size="small" v-model="ruleForm.ruleMessage" clearable placeholder="请输入"></el-input>
              </el-form-item>
              <div style="width:100%;height:1px;border-top:0.5px solid rgba(0, 0, 0, 0.12);"></div>
              <el-form-item label="规则类型:" label-width="84px" prop="ruleType" class="short-input small-text">
                <el-select
                  size="small"
                  v-model="ruleForm.ruleType"
                  :disabled="curStatus === pageStatus.edit"
                  placeholder="请选择规则类型"
                  @change="changeRuleType">
                  <el-option
                    v-for="item in options.ruleTypeOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="规则状态:" label-width="84px" class="short-input small-text">
                <el-switch
                  v-model="ruleForm.status"
                  active-color="#13ce66"
                  inactive-color="#ff4949"
                  :active-value="1"
                  :inactive-value="0"
                >
                </el-switch>
              </el-form-item>
              <div class="ky-red-text" style="font-size:12px;margin-bottom: 5px;">{{options.ruleTypeTextOptions[ruleForm.ruleType - 1]}}</div>
              <div class="change-box">
                <div style="font-weight: bold;font-size: 12px;">{{options.ruleTypeLabelOptions[ruleForm.ruleType - 1]}}</div>
                <!--  <div v-for="(obj,index) in treeList" :key="index"> -->

                <!-- </div> -->
                <!-- <div style="font-weight: bold;font-size: 12px;" v-if="ruleForm.ruleType === 3 || ruleForm.ruleType === 4">则:{{ruleForm.ruleType === 3 ? '仅可预约':'无法预约'}}</div> -->
                <div style="padding:0px 10px">
                  <!-- <el-form-item label="检查规则:" v-show="ruleForm.ruleType=== 1 || ruleForm.ruleType=== 2 || ruleForm.ruleType=== 6" class="m-b-0 small-font small-tag"> -->
                  <div class="rule_box_title">
                    <div class="tit">
                      <span>检查规则:</span>
                      <el-tooltip class="item" effect="dark" :content="ruleExplain" placement="top-start">
                        <i class="el-icon-info"></i>
                      </el-tooltip>

                      <span
                        class="form-a small-font ky-ml20"
                        @click="addConditionGround">
                        <i class="el-icon-files icon"></i> 添加规则组
                      </span>
                    </div>
                    <div class="rule_styles">
                      <div
                        class="rule_style_item"
                        v-for="item in ruleConditionGroupOptions"
                        :key="item.value"
                      ><i :class="'rs_icon rs_icon'+item.value"></i>{{item.label.replace('预约', '')}}</div>
                    </div>
                  </div>
                  <el-form-item class="m-b-0 small-font small-tag">
                    <div
                      class="rule_cont_group"
                      v-for="(ruleCont, index) in ruleConts"
                      :key="index"
                    >
                      <ruleItemBox
                        :ref="`'${'ruleItemBox_'+index}'`"
                        :hospital-code="ruleForm.hospitalCode"
                        :dep="ruleForm.dep"
                        :rcg-options="ruleConditionGroupOptions"
                        :rc-options="ruleConditionOptions"
                        :rule-list="ruleCont"
                        :init-multiple="ruleForm.ruleType===9"
                        :content-group="index"
                        @delGroup="delGroup"
                        @copyGroup="copyGroup"
                      />
                    </div>
                    <div class="rule_group_tips">提示：规则组之间的判断为“或”的关系</div>
                  </el-form-item>
                </div>
                <!-- 优先 -->
                <!-- <div style="font-weight: bold;font-size: 12px;" v-if="ruleForm.ruleType === 1 || ruleForm.ruleType === 6">则:{{ruleForm.ruleType !== 6 ?'仅可预约':''}}</div> -->
                <div style="padding:0px 10px">
                  <!-- <el-form-item v-if="ruleForm.ruleType===6 || ruleForm.ruleType===5 || ruleForm.ruleType===7" label="优先级:" prop="priority" class="last-input m-b-0 small-font"> -->
                  <el-form-item label="优先级:" prop="priority" class="last-input m-b-0 small-font">
                    <el-input style="width:187px" size="small" v-model.number="ruleForm.priority" :min="1" label="优先级"></el-input>
                  </el-form-item>
                  <!-- 时限 -->
                  <el-form-item v-if="ruleForm.ruleType===1" label="时间范围:" class="time-form small-font">
                    <el-input prefix-icon="el-icon-time" style="width:130px" size="small" v-set-default="null" clearable v-model.number="ruleForm.begintime" :min="1" label="请输入"></el-input>
                    <span style="margin: 0 7px;">~</span>
                    <el-input prefix-icon="el-icon-time" style="width:130px" size="small" v-set-default="null" clearable v-model.number="ruleForm.endtime" :min="ruleForm.begintime" label="请输入"></el-input>
                    <el-select size="small" v-model="ruleForm.begintimeunit" placeholder="请选择" class="timeType">
                      <el-option
                        v-for="item in options.dateTypeOptions"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                  <!-- <el-form-item v-if="ruleForm.ruleType===2" label="时段:" prop="worktime" class="last-input m-b-0 small-font">
                      <el-select size="small" v-model="ruleForm.worktime" placeholder="请选择规则类型">
                        <el-option
                          v-for="item in options.timeRangeOptions"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value"
                        ></el-option>
                      </el-select>
                    </el-form-item> -->
                  <el-form-item
                    v-else-if="ruleForm.ruleType===3 || ruleForm.ruleType===6"
                    :label="ruleForm.ruleType === 3 ? '前置检查时间间隔:' : '优先检查时间间隔：'"
                    class="last-input m-b-0 small-font">
                    <el-input
                      prefix-icon="el-icon-time"
                      size="small"
                      v-set-default="null"
                      clearable
                      v-model.number="ruleForm.begintime"
                      :min="1"
                      label="时间范围"></el-input>
                    <el-select size="small" v-model="ruleForm.begintimeunit" placeholder="请选择" class="timeType">
                      <el-option
                        v-for="item in options.dateTypeOptions"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                      ></el-option>
                    </el-select>
                    <span>之内</span>
                  </el-form-item>
                  <!-- 优先、排斥 -->
                  <el-form-item
                    v-else-if="ruleForm.ruleType===4"
                    label="排斥检查时间间隔:"
                    class="last-input m-b-0 small-font">
                    <el-input
                      refix-icon="el-icon-time"
                      size="small"
                      type="number"
                      clearable
                      v-set-default="null"
                      v-model.number="ruleForm.endtime"
                      :min="1"
                      label="时间范围"></el-input>
                    <el-select size="small" v-model="ruleForm.endtimeunit" placeholder="请选择" class="timeType">
                      <el-option
                        v-for="item in options.dateTypeOptions"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                      ></el-option>
                    </el-select>
                    <span>之前</span>
                  </el-form-item>
                </div>
                <div style="font-weight: bold;font-size: 12px;" v-if="![2,5,6,7,8,9,10].includes(ruleForm.ruleType)">的检查</div>
              </div>
            </div>
            <div class="rule_checkpartbox change-box">
              <!-- <div style="font-weight: bold;font-size: 12px;">{{options.ruleTypeLabelOptions[ruleForm.ruleType - 1]}}</div> -->
              <el-tabs v-model="activeName" @tab-click="handleClick">
                <el-tab-pane label="检查类型" name="first">
                  <div style="padding:0px 10px">
                    <el-form-item label="检查类型:" class="check_type_search">
                      <el-select v-model="checkType" placeholder="过滤条件" multiple clearable size="small" class="check_select">
                        <el-option
                          v-for="item in checkTypeTreeOptions"
                          :key="item"
                          :label="item"
                          :value="item"
                        ></el-option>
                      </el-select>
                      <el-input prefix-icon="el-icon-search" v-model="filterText" size="small" placeholder="请输入内容" class="check_ipt">
                        <el-select v-model="checkTypeSelectFilter" slot="append" placeholder="全部" clearable class="ipt_apend">
                          <el-option label="大部位" value="2"></el-option>
                          <el-option label="小部位" value="3"></el-option>
                        </el-select>
                      </el-input>
                    </el-form-item>
                    <!-- <el-form-item>
                    </el-form-item> -->
                    <el-form-item class="inline-block tree" prop="ruleTypes">
                      <tree
                        v-if="showTree"
                        ref="tree"
                        :data="checkTypeData"
                        show-checkbox
                        node-key="id"
                        @check="handleCheckChange"
                        :auto-expand-parent="false"
                        :props="defaultProps"
                        :filter-node-method="filterNode"
                        render-after-expand
                        :height="680">
                      </tree>
                    </el-form-item>
                  </div>
                </el-tab-pane>
                <el-tab-pane :label="categoryType[ruleForm.ruleType]" name="second" v-if="ruleForm.ruleType=== 3 || ruleForm.ruleType=== 4 || ruleForm.ruleType=== 5 || ruleForm.ruleType=== 7 || ruleForm.ruleType=== 8">
                  <div style="padding: 0 10px;">
                    <el-form-item :label="categoryType[ruleForm.ruleType]" class="check_type_search">
                      <el-select v-model="checkOtherType" placeholder="过滤条件" multiple clearable size="small" class="check_select">
                        <el-option
                          v-for="item in checkTypeTreeOptions"
                          :key="item"
                          :label="item"
                          :value="item"
                        ></el-option>
                      </el-select>
                      <el-input prefix-icon="el-icon-search" v-model="filterTextOther" size="small" placeholder="请输入内容" class="check_ipt">
                        <el-select v-model="checkTypeSelectFilterOther" slot="append" placeholder="全部" clearable class="ipt_apend">
                          <el-option label="大部位" value="2"></el-option>
                          <el-option label="小部位" value="3"></el-option>
                        </el-select>
                      </el-input>
                    </el-form-item>
                    <!-- <el-form-item>
                    </el-form-item> -->
                    <el-form-item class="inline-block tree" prop="ruleOtherTypes">
                      <tree
                        v-if="showTree"
                        ref="treeOther"
                        :data="checkOtherTypeData"
                        show-checkbox
                        node-key="id"
                        @current-change="handleOtherCheckChange"
                        @check="handleOtherCheckChange"
                        :auto-expand-parent="false"
                        :props="defaultProps"
                        :filter-node-method="filterOtherNode"
                        render-after-expand
                        :height="680">
                      </tree>
                    </el-form-item>
                  </div>
                </el-tab-pane>
                <el-tab-pane :label="categoryType[ruleForm.ruleType]" name="third" v-if="ruleForm.ruleType=== 8">
                  <div style="padding: 0 10px;">
                    <el-form-item :label="categoryType[ruleForm.ruleType]" class="check_type_search">
                      <el-select v-model="checkOtherType2" placeholder="过滤条件" multiple clearable size="small" class="check_select">
                        <el-option
                          v-for="item in checkTypeTreeOptions"
                          :key="item"
                          :label="item"
                          :value="item"
                        ></el-option>
                      </el-select>
                      <el-input prefix-icon="el-icon-search" v-model="filterTextOther2" size="small" placeholder="请输入内容" class="check_ipt">
                        <el-select v-model="checkTypeSelectFilterOther2" slot="append" placeholder="全部" clearable class="ipt_apend">
                          <el-option label="大部位" value="2"></el-option>
                          <el-option label="小部位" value="3"></el-option>
                        </el-select>
                      </el-input>
                    </el-form-item>
                    <!-- <el-form-item>
                    </el-form-item> -->
                    <el-form-item class="inline-block tree" prop="ruleOtherTypes2">
                      <tree
                        v-if="showTree"
                        ref="treeOther2"
                        :data="checkOtherTypeData2"
                        show-checkbox
                        node-key="id"
                        @current-change="handleOtherCheckChange2"
                        @check="handleOtherCheckChange2"
                        :auto-expand-parent="false"
                        :props="defaultProps"
                        :filter-node-method="filterOtherNode2"
                        render-after-expand
                        :height="680">
                      </tree>
                    </el-form-item>
                  </div>
                </el-tab-pane>
              </el-tabs>
            </div>
          </div>
        </el-form>
      </div>
      <div class="buttons">
        <el-popover
          placement="top-start"
          title="预约规则说明"
          width="400"
          trigger="hover">
          <div class="rule_explain">
            <div class="rule_e_item">1、顺序规则>合并规则>拆分规则>时段条件规则>时段规则>时限规则>前置规则>排斥规则>优先规则</div>
            <div class="rule_e_item">2、合并规则的子申请单不判断其他规则</div>
            <div class="rule_e_item">3、拆分规则的子申请单判断其他规则，主申请单不判断</div>
            <div class="rule_e_item">4、孕周规则主要对孕周检查的时段号源查询判断过滤</div>
          </div>
          <div slot="reference" class="rule_explain_btn"><i class="el-icon-info"></i> 规则说明</div>
        </el-popover>
        <div class="right-buttons">
          <span style="margin-right:20px;color:#ff7600d6"><i class="el-icon-info"></i>编辑完成提交后规则生效</span>
          <el-button v-if="curStatus === pageStatus.edit" class="floatR m-l-1" type="warning" :loading="saveLoading" size="small" @click="newConfirm('form')">以此模板新增</el-button>
          <el-button v-if="ruleForm.ruleType === 10 && curStatus === pageStatus.edit" type="primary" plain class="floatR" size="small" @click="handleOpenRecored">号源记录</el-button>
          <el-button class="floatR" size="small" @click="handleClose">关闭</el-button>
          <el-button class="floatR" size="small" @click="handleReset">重置</el-button>
          <el-button class="floatR m-l-1" type="primary" :loading="saveLoading" size="small" @click="handleConfirm('form')">提交</el-button>
        </div>
      </div>
    </Dialogdrawerdefect>
  </div>
</template>

<script>
import { addTimeLimitRule, addTimeIntervalRule,
  addRelationRule, addExcludeRule, addSequenceRule, addPriorRule, addMergerule,
  addSplitrule, addtimeconditionrule, addnumberscale, addgestationalweekrule,
  addexamlimitrule, editexamlimitrule, addchangerule, editchangerule, addcancelrule, editcancelrule,
  editSplitrule, editTimeLimitRule, editTimeIntervalRule, editRelationRule,
  editExcludeRule, editSequenceRule, editPriorRule,
  editMergerule, edittimeconditionrule, editnumberscalerule, editgestationalweekrule,
  getHisDepTree, getAppointmentRuleContentList, getRuleTypeList,
  getItemDicList, getDepList } from '@/api/api.js'
import { PageStatus, Options } from '@/utils/constant'
import Dialogdrawerdefect from '@/components/dialogbox/dialogDrawerDefect'
import Tree from '@/assets/js/tree/index.js'
import getDicOptions from '@/mixin/getDicOptions'
import ruleItemBox from './comp/ruleItemGroup'
import { yzRule, defaultRule } from '@/utils/ruleAddDefault'

// const ruleItemObj = {
//   ruleCondition: '',
//   conditionCode: null,
//   conditionValue: '',
//   ruleConditionId: '',
//   controllType: '',
//   modelType: null,
//   signFilterOptions: [],
//   conditionSelectValueOptions: []
// }
const { body } = document
export default {
  name: '',
  mixins: [getDicOptions],
  components: { Dialogdrawerdefect, Tree, ruleItemBox },
  props: {
    rowData: {
      type: Object,
      default: () => {}
    },
    visible: {
      type: Boolean,
      default: false
    },
    curStatus: {
      required: true
    },
    hospitalCode: {
      type: String,
      default: '',
      required: true
    }
  },
  data() {
    return {
      dlgShowFlag: false, // 判断弹框第一次打开，加载部分数据
      dlgWidth: '70%', // 弹框的宽度
      showTree: true,
      showRight: false,
      saveLoading: false,
      sendNew: false, // 是否当前模板新增提交
      options: Options,
      checkTypeTreeOptions: [],
      pageStatus: PageStatus,
      editName: '',
      checkType: [],
      checkOtherType: [],
      checkOtherType2: [],
      checkTypeData: [],
      checkOtherTypeData: [],
      checkOtherTypeData2: [],
      checkTypeSelectFilter: '',
      checkTypeSelectFilterOther: '',
      checkTypeSelectFilterOther2: '',
      filterIds: [],
      filterOtherIds: [],
      filterOtherIds2: [],
      filterText: '',
      treeList: [],
      filterTextOther: '',
      filterTextOther2: '',
      ruleForm2: {},
      defaultProps: {
        children: 'childrens',
        label: 'text'
      },
      ruleConditionOptions: [], // 规则数据字典
      ruleConditionGroupOptions: [], // 规则数据字典
      ruleExplain: '说明：检查规则，按规则匹配可预约时段，规则组之间条件判断为或关系',
      categoryType: ['', '', '', '前置检查内容', '排斥检查类型', '顺序检查类型', '', '合并检查类型', '拆分检查类型'],
      placeholderKey: [], // 记录切换控件显示的默认提醒
      ruleForm: {
        ruleContents: [ // 规则内容
          // JSON.parse(JSON.stringify(ruleItemObj))
        ],
        ruleName: '',
        ruleDescribe: '',
        ruleMessage: '',
        status: 1,
        hospitalCode: '',
        dep: '',
        ruleType: 2, // 规则类型
        begintimeunit: 1, // 时间类型
        endtimeunit: 1,
        begintime: null,
        endtime: null,
        // worktime: 1, // 时段
        priority: 1, // 优先级
        ruleTypes: [], // 规则类型
        ruleOtherTypes: [], // 其它规则类型
        ruleOtherTypes2: []// 其它规则类型
      },
      rules: {
        hospitalCode: [{ required: true, message: '请选择医院', trigger: 'blur' }],
        // ruleDescribe: [{ required: true, message: '请输入规则描述', trigger: 'blur' }],
        ruleName: [{ required: true, message: '请输入规则名称', trigger: 'blur' }],
        ruleType: [{ required: true, message: '请选择规则类型', trigger: 'blur' }],
        // begintimeunit: [{ required: true, message: '请选择时间范围', trigger: 'blur' }],
        // ruleTypes: [ { required: true, message: "请选择检查类型", trigger: "blur" } ],
        // ruleOtherTypes: [ { required: true, message: "请选择检查类型", trigger: "blur" } ],
        // worktime: [{ required: true, message: '请选择时段', trigger: 'blur' }],
        priority: [{ required: true, message: '请选择优先级', trigger: 'blur' }]
      },
      // 规则内容，规则组数据
      ruleConts: [],

      // 检查项目
      activeName: 'first'
    }
  },
  watch: {
    visible(val) {
      this.showRight = val
      this.activeName = 'first'
      if (!this.dlgShowFlag && val) {
        this.dlgShowFlag = true
        this.saveLoading = true
        Promise.all([this.getHisTree(), this.getItemList(), this.getCheckTypeTreeOptions()]).then(res => {
          this.saveLoading = false
          if (this.rowData.id) {
            // 防止首次打开为编辑规则时，与获取规则数据的先后问题数据不显示修复
            this.rowClick(this.rowData)
            this.editName = this.rowData.ruleName
          } else {
            this.rowDefault(this.rowData)
          }
        }).catch(() => {
          this.saveLoading = false
        })
      }
    },
    curStatus(val) {
      this.clearFilter()
      this.$nextTick(() => {
        this.$refs.form && this.$refs.form.clearValidate()
      })
    },
    rowData(data) {
      // 防止首次打开为编辑规则时，与获取规则数据的先后问题数据不显示修复 this.dlgShowFlag && !this.saveLoading 防止重复请求
      if (data && this.dlgShowFlag && !this.saveLoading) {
        this.activeName = 'first'
        if (data.id) {
          this.rowClick(data)
          this.editName = data.ruleName
        } else {
          this.rowDefault(data)
        }
      }
    },
    hospitalCode: {
      async handler(val) {
        this.ruleForm.hospitalCode = val
        if (this.dlgShowFlag) {
          this.getHisTree()
          // 获取规则配置（数据字典内容）
          this.getItemList()
          this.getCheckTypeTreeOptions()// 获取检查类型
        }
      },
      immediate: true
    },
    filterText(val) {
      this.filterTree('tree', this.checkType, val)
    },
    checkType(val) {
      this.filterIds = []
      this.filterTree('tree', val, this.filterText)
    },
    checkTypeSelectFilter() {
      this.filterTree('tree', this.checkType, this.filterText)
    },
    filterTextOther(val) {
      this.filterTree('treeOther', this.checkOtherType, val)
    },
    checkOtherType(val) {
      this.filterOtherIds = []
      this.filterTree('treeOther', val, this.filterTextOther)
    },
    checkTypeSelectFilterOther() {
      this.filterTree('treeOther', this.checkOtherType, this.filterTextOther)
    },
    filterTextOther2(val) {
      this.filterTree('treeOther2', this.checkOtherType2, val)
    },
    checkOtherType2(val) {
      this.filterOtherIds2 = []
      this.filterTree('treeOther2', val, this.filterTextOther2)
    },
    checkTypeSelectFilterOther2() {
      this.filterTree('treeOther2', this.checkOtherType2, this.filterTextOther2)
    }
  },
  filters: {
    flrModelTypeText(val) {
      let txt = ''
      const _obj = Options.modelTypeOptions.find(item => item.value === val)
      if (_obj) {
        txt = _obj.label
      }
      return txt
    }
  },
  created() {
    this.ruleForm.hospitalCode = this.$store.state.user.hospitalCode || ''
    this.handleReset()
    console.log('打开规则组')
  },
  mounted() {
    this.$_resizeHandler()
  },
  methods: {
    filterTree($el, val1, val2) {
      this.$refs[`${$el}`] && this.$refs[`${$el}`].filter(val1)
      this.$refs[`${$el}`] && this.$refs[`${$el}`].filter(val2)
    },
    handleClick(tab, event) {
      // console.log(tab, event)
    },
    handleOpenRecored() {
      this.$emit('openSourceInfo', this.ruleForm.hospitalCode, this.ruleForm.id)
    },
    handleClose() {
      this.handleReset()
      this.$emit('update:rowData', null)
      this.$emit('update:visible', false)
    },
    handleReset() {
      let ruleForm = {
        id: '',
        ruleName: '',
        ruleDescribe: '',
        ruleMessage: '',
        begintimeunit: 1,
        endtimeunit: 1,
        ruleType: 2,
        begintime: null,
        endtime: null,
        priority: 1,
        status: 1,
        hospitalCode: this.hospitalCode,
        ruleContents: [
          // JSON.parse(JSON.stringify(ruleItemObj))
        ],
        ruleTypes: [], // 选择的树的节点
        ruleOtherTypes: [], // 选择的树的节点
        ruleOtherTypes2: []// 选择的树的节点
      }
      this.ruleForm = Object.assign({}, this.ruleForm, ruleForm)

      this.ruleFormSendData = null
      this.ruleConts = [[...defaultRule]]
      this.$refs.tree && this.$refs.tree.setCheckedKeys([])
      this.$refs.treeOther && this.$refs.treeOther.setCheckedKeys([])
      this.$refs.treeOther2 && this.$refs.treeOther2.setCheckedKeys([])
      this.ruleForm2 = {}
      this.clearFilter()
      this.checkFlag = false
      this.checkFlagOther = false
      this.checkFlagOther2 = false
      this.setRuleConditionGroup()
    },
    // 确认修改或新增
    handleConfirm(formName) {
      if (this.curStatus === this.pageStatus.add) {
        this.handleAdd(formName)
      } else if (this.curStatus === this.pageStatus.edit) {
        this.sendNew = false
        this.handleEdit(formName)
      }
    },
    newConfirm(formName) {
      this.$confirm('是否以此模板新增规则?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.handleAdd(formName)
      }).catch(() => {})
    },
    handleAdd(formName) {
      this.$refs[formName].validate((valid, object) => {
        if (valid) {
          this.sendNew = true
          this.getTypeApi(this.ruleForm.ruleType)
        } else {
          for (let k in object) {
            this.$message.warning(object[k][0].message)
            return
          }
        }
      })
    },
    // 通过这个方法获取对应规则类型的的新增或修改的方法
    getTypeApi(type) {
      /**
      { value: 2, label: '时段规则' },
      { value: 1, label: '时限规则' },
      { value: 3, label: '前置规则' },
      { value: 4, label: '排斥规则' },
      { value: 5, label: '顺序规则' },
      { value: 6, label: '优先规则' },
      { value: 7, label: '合并规则' },
      { value: 8, label: '拆分规则' },
      { value: 11, label: '孕周规则' },
      { value: 9, label: '时段条件规则' },
      { value: 10, label: '号源比例规则' }
        */
      // this.$refs.ruleItemBox.getRuleData()
      this.ruleFormSendData = JSON.parse(JSON.stringify(this.ruleForm))
      // 进行判断 其它检查类型（3，4，5, 7, 8）需要添加的时候 ruleOtherTypes不能空
      const otherType = [3, 4, 5, 7, 8] // 有其它类型的检查类型
      const otherType2 = [8]// 有第三棵树
      // const requiredType = [1, 2, 6, 10]// 检查规则必填且要有号源时段或者时段限制条件
      let examCycleFlag = 0 // 限制周期，孕周规则必填项判断
      // const rType = [1, 2, 6] // 存在检查内容
      // if (!rType.includes(this.ruleFormSendData.ruleType) && (!this.ruleForm2.ruleTypes || this.ruleForm2.ruleTypes.length === 0)) {
      if (!this.ruleForm2.ruleTypes || this.ruleForm2.ruleTypes.length === 0) {
        this.$message.warning('请选择检查类型')
        return
      }
      if (otherType.includes(this.ruleFormSendData.ruleType) && (!this.ruleForm2.ruleOtherTypes || this.ruleForm2.ruleOtherTypes.length === 0)) {
        this.$message.warning('请选择相应的检查类型')
        return
      }
      if (otherType2.includes(this.ruleFormSendData.ruleType) && (!this.ruleForm2.ruleOtherTypes2 || this.ruleForm2.ruleOtherTypes2.length === 0)) {
        this.$message.warning('请选择相应的拆分类型')
        return
      }
      this.ruleFormSendData.ruleTypes = this.ruleForm2.ruleTypes
      if (otherType.includes(this.ruleFormSendData.ruleType)) {
        // 当有其它检查类型的时候 合并
        let newTypeArr = this.ruleForm2.ruleTypes.concat(this.ruleForm2.ruleOtherTypes)
        this.ruleFormSendData.ruleTypes = [...newTypeArr]
      }
      if (otherType2.includes(this.ruleFormSendData.ruleType)) {
        // 当有拆分类型的时候 合并
        let newTypeArr = this.ruleFormSendData.ruleTypes.concat(this.ruleForm2.ruleOtherTypes2)
        this.ruleFormSendData.ruleTypes = [...newTypeArr]
      }

      // 验证检查规则组
      const ruleGroupData = this.getGroupAllData()
      console.log('ruleGroupData', ruleGroupData)
      let rgvFlag = false
      for (let ri = 0; ri < ruleGroupData.length; ri++) {
        const resRuleContents = this.contentGroupValid(ruleGroupData[ri], this.ruleFormSendData.ruleType, ri)
        // console.log('resRuleContents', resRuleContents)
        if (!resRuleContents) {
          rgvFlag = true
        } else {
          ruleGroupData[ri] = resRuleContents
        }
      }
      if (rgvFlag) return false
      // 规则的二维数组，转一维数组
      const ruleGroupList = ruleGroupData.reduce((a, b) => a.concat(b))
      console.log('ruleGroupList', ruleGroupList)
      // const ruleTypes = this.$refs.ruleItemBox && this.$refs.ruleItemBox.getRuleData() || []
      this.ruleFormSendData.ruleContents = ruleGroupList

      // 时间范围检查
      const bTime = this.ruleFormSendData.begintime
      const eTime = this.ruleFormSendData.endtime
      if (this.ruleFormSendData.ruleType === 1 && ((!bTime && bTime !== 0) || (!eTime && eTime !== 0))) { // 时限
        this.$message.warning('请填写时间范围')
        return
      }
      if (this.ruleFormSendData.ruleType === 1 && bTime >= eTime) { // 时限
        this.$message.warning('开始时间要小于结束时间')
        return
      }
      if (this.ruleFormSendData.ruleType === 3 && !bTime && bTime !== 0) { // 时限
        this.$message.warning('请填写时间间隔')
        return
      }
      if (this.ruleFormSendData.ruleType === 4 && !eTime && eTime !== 0) { // 时限
        this.$message.warning('请填写时间间隔')
        return
      }

      if (otherType.includes(this.ruleFormSendData.ruleType)) { // 属于3,4,5,7,8两棵树
        this.ruleFormSendData.ruleTypes.forEach(v => {
          if (v.ruleCategory !== 1) {
            v.ruleCategory = this.ruleFormSendData.ruleType
          }
        })
      }
      if (this.ruleFormSendData.ruleType === 7 || this.ruleFormSendData.ruleType === 8) { // 合并拆分
        let judgeData = this.ruleFormSendData.ruleTypes[0].dep
        let flag = this.ruleFormSendData.ruleTypes.every((v) => {
          return judgeData === v.dep
        })
        if (!flag) {
          this.$message.warning('检查类型必须相同')
          return
        }

        if (this.ruleFormSendData.ruleTypes[0].dep === this.ruleFormSendData.ruleTypes[1].dep && this.ruleFormSendData.ruleTypes[0].dengjipart === this.ruleFormSendData.ruleTypes[1].dengjipart && this.ruleFormSendData.ruleTypes[0].checkpos === this.ruleFormSendData.ruleTypes[1].checkpos) {
          this.$message.warning('检查项目不能相同')
          return
        }
      }
      if (this.ruleFormSendData.ruleType === 11 && examCycleFlag === 1) {
        // 孕周规则，限制周期规则必填
        this.$message.warning('孕周需有开始与结束两个孕周规则')
        return
      }
      if (this.ruleFormSendData) {
        console.log('ruleFormSendData', JSON.parse(JSON.stringify(this.ruleFormSendData)))
      }
      console.log('typetypetypetype', type)
      switch (type) {
        case 1: // 时限
          this.curStatus === this.pageStatus.add || this.sendNew ? this.addTimeRule() : this.editTimeRule()
          break
        case 2: // 时段
          this.curStatus === this.pageStatus.add || this.sendNew ? this.addInterval() : this.editInterval()
          break
        case 3: // 关联
          this.curStatus === this.pageStatus.add || this.sendNew ? this.addRelation() : this.editRelation()
          break
        case 4: // 排斥
          this.curStatus === this.pageStatus.add || this.sendNew ? this.addExclude() : this.editExclude()
          break
        case 5: // 序列
          this.curStatus === this.pageStatus.add || this.sendNew ? this.addSequence() : this.editSequence()
          break
        case 6: // 优先
          this.curStatus === this.pageStatus.add || this.sendNew ? this.addPrior() : this.editPrior()
          break
        case 7: // 合并
          this.curStatus === this.pageStatus.add || this.sendNew ? this.addMerge() : this.editMerge()
          break
        case 8: // 拆分
          this.curStatus === this.pageStatus.add || this.sendNew ? this.addSplit() : this.editSplit()
          break
        case 9: // 时段条件
          this.curStatus === this.pageStatus.add || this.sendNew ? this.addIntervalCondition() : this.editIntervalCondition()
          break
        case 10: // 号源比例
          this.curStatus === this.pageStatus.add || this.sendNew ? this.addProportionCondition() : this.editProportionCondition()
          break
        case 11: // 孕周
          this.curStatus === this.pageStatus.add || this.sendNew ? this.addgestationalweekrule() : this.editgestationalweekrule()
          break
        case 12: // 申请单约束条件
          this.curStatus === this.pageStatus.add || this.sendNew ? this.addexamlimitrule() : this.editexamlimitrule()
          break
        case 14: // 改约
          this.curStatus === this.pageStatus.add || this.sendNew ? this.addchangerule() : this.editchangerule()
          break
        case 15: // 取消预约
          this.curStatus === this.pageStatus.add || this.sendNew ? this.addcancelrule() : this.editcancelrule()
          break
        default:
          break
      }
    },
    // 验证规则组的数据是否填写
    contentGroupValid(ruleContents, ruleType, groupIdx) {
      const msg_pre = `规则组${groupIdx + 1}：`
      // const otherType = [3, 4, 5, 7, 8] // 有其它类型的检查类型，多个检查类型数
      let examCycleFlag = 0 // 限制周期，孕周规则必填项判断
      const requiredType = [1, 2, 6, 10, 4, 7, 8]// 检查规则必填且要有号源时段或者时段限制条件 478 申请单必填
      const msgRun = (txt) => {
        this.$message.warning(msg_pre + txt)
      }

      // 过滤没有选择的规则
      ruleContents = ruleContents.filter(rc => {
        return rc.ruleCondition
      })

      // 判断选择号源比例，前提必须选择申请单规则
      const pArr = ruleContents.find(item => item.modelType === 4)
      if (pArr) {
        const aObj = ruleContents.find(item => item.modelType === 3)
        if (!aObj) {
          msgRun('设置号源比例的规则，须设置申请单的规则')
          return false
        }
      }

      if (ruleType === 9) {
        if ((ruleContents.length === 0)) {
          msgRun('请填写相应的规则内容')
          return
        }
        let modelType = ruleContents[0].modelType
        let flag = ruleContents.some((item, index) => {
          return modelType != item.modelType
        })
        if (!flag || ruleContents.length < 2) {
          msgRun('请填写申请单和号源时段检查规则')
          return
        }
      }

      if (requiredType.includes(ruleType)) {
        if (ruleContents.length === 0) {
          msgRun('请填写相应的规则内容')
          return
        }
        let flag1 = false// 号源时段
        let flag2 = false// 时段限制条件
        let flag3 = false// 申请单
        let flag4 = false// 号源比例
        ruleContents.forEach(v => {
          if (v.modelType === 3) {
            flag3 = true
          } else if (v.modelType === 4) {
            flag4 = true
          } else if (v.modelType === 1) {
            flag1 = true
          } else if (v.modelType === 2) {
            flag2 = true
          }
        })
        if (!flag3 && [4, 7, 8].includes(this.ruleFormSendData.ruleType)) {
          msgRun('请填写检查规则的申请单规则')
          return
        }
        if ([1, 2, 6].includes(ruleType)) {
          if (!flag1 && !flag2) {
            msgRun('请填写号源时段或时段限制条件规则')
            return
          }
        } else if (this.ruleFormSendData.ruleType === 10) { // 10
          if (!flag1) {
            msgRun('请填写号源时段')
            return
          }
          if (!flag4) {
            msgRun('请填写号源比例')
            return
          }
        }
      }

      if (ruleContents.length > 0) {
        // content的数据格式转换
        let delIndex
        let tempCondition = {}
        // 内容的value必须是字符串（不能是数组和int）
        for (let i = 0; i < ruleContents.length; i++) {
          // 判断是否为空 conditionValue默认是0 就不判断了
          if (!(ruleContents[i].ruleCondition) ||
               !(ruleContents[i].conditionCode) ||
               ruleContents[i].conditionValue === null ||
               ruleContents[i].conditionValue === undefined ||
               ruleContents[i].conditionValue === '' ||
               (typeof ruleContents[i].conditionValue === 'object' && ruleContents[i].conditionValue.length === 0)
          ) {
            msgRun('请填写相应的规则内容')
            return
          }
          if (ruleContents[i].ruleCondition === 'GestationalWeek') {
            // 限制周期是否有选择判断，后面有根据是否孕周规则做判断提示
            examCycleFlag = examCycleFlag + 1
          }
          // 如果是int 要改成字符串形式
          if (typeof ruleContents[i].conditionValue === 'number') {
            // 如果是int
            delIndex = i
            tempCondition = {
              ruleCondition: ruleContents[i].ruleCondition,
              conditionCode: ruleContents[i].conditionCode,
              conditionValue: ruleContents[i].conditionValue.toString(),
              conditionControl: ruleContents[i].conditionControl,
              controllType: ruleContents[i].controllType,
              modelType: ruleContents[i].modelType
            }
            delete ruleContents[delIndex]
            ruleContents[delIndex] = { ...tempCondition }
          } else if (typeof ruleContents[i].conditionValue === 'object') {
            // 如果是数组 要改成字符串形式
            delIndex = i
            let conditionValue = ruleContents[i].conditionValue.join(',')
            if (!(ruleContents[i].ruleCondition && conditionValue)) {
              msgRun('请填写相应的规则内容')
              return
              // continue
            }
            tempCondition = {
              ruleCondition: ruleContents[i].ruleCondition,
              conditionCode: ruleContents[i].conditionCode,
              conditionValue: conditionValue || '',
              conditionControl: ruleContents[i].conditionControl,
              controllType: ruleContents[i].controllType,
              conditionSelectValueOptions: ruleContents[i].conditionSelectValueOptions,
              modelType: ruleContents[i].modelType
            }
            delete ruleContents[delIndex]
            ruleContents[delIndex] = { ...tempCondition }
          } else {
            // 控件类型
            console.log(ruleContents[i].controllType)
            // 字符串类型
            if (!(ruleContents[i].ruleCondition && ruleContents[i].conditionValue)) {
              msgRun('请填写相应的规则内容')
              return
              // continue
            }
          }
        }
      }
      return ruleContents
    },
    // 时限规则添加
    addTimeRule() {
      this.ruleFormSendData.endtimeunit = this.ruleFormSendData.begintimeunit
      this.saveLoading = true
      addTimeLimitRule(this.ruleFormSendData).then(res => {
        if (res && res.code === 10000) {
          this.$message.success('时限规则添加成功')
          this.fetchData()
          this.handleClose()
        }
        this.saveLoading = false
      })
    },
    // 修改时段
    addInterval() {
      this.saveLoading = true
      addTimeIntervalRule(this.ruleFormSendData).then(res => {
        if (res && res.code === 10000) {
          this.$message.success('时段规则添加成功')
          this.fetchData()
          this.handleClose()
        }
        this.saveLoading = false
      })
    },
    // 孕周规则
    addgestationalweekrule() {
      this.saveLoading = true
      addgestationalweekrule(this.ruleFormSendData).then(res => {
        if (res && res.code === 10000) {
          this.$message.success('孕周规则添加成功')
          this.fetchData()
          this.handleClose()
        }
        this.saveLoading = false
      })
    },
    // 申请单约束条件
    addexamlimitrule() {
      this.saveLoading = true
      addexamlimitrule(this.ruleFormSendData).then(res => {
        if (res && res.code === 10000) {
          this.$message.success('申请单约束条件添加成功')
          this.fetchData()
          this.handleClose()
        }
        this.saveLoading = false
      })
    },
    // 新增改约
    addchangerule() {
      this.saveLoading = true
      addchangerule(this.ruleFormSendData).then(res => {
        if (res && res.code === 10000) {
          this.$message.success('改约规则添加成功')
          this.fetchData()
          this.handleClose()
        }
        this.saveLoading = false
      })
    },
    // 新增取消预约
    addcancelrule() {
      this.saveLoading = true
      addcancelrule(this.ruleFormSendData).then(res => {
        if (res && res.code === 10000) {
          this.$message.success('取消预约规则添加成功')
          this.fetchData()
          this.handleClose()
        }
        this.saveLoading = false
      })
    },
    // 修改取消预约规则
    editcancelrule() {
      this.saveLoading = true
      editcancelrule(this.ruleFormSendData).then(res => {
        if (res && res.code === 10000) {
          this.$message.success('取消预约规则修改成功')
          this.fetchData()
          this.handleClose()
        }
        this.saveLoading = false
      })
    },
    editexamlimitrule() {
      this.saveLoading = true
      editexamlimitrule(this.ruleFormSendData).then(res => {
        if (res && res.code === 10000) {
          this.$message.success('申请单约束条件修改成功')
          this.fetchData()
          this.handleClose()
        }
        this.saveLoading = false
      })
    },
    // 修改改约
    editchangerule() {
      this.saveLoading = true
      editchangerule(this.ruleFormSendData).then(res => {
        if (res && res.code === 10000) {
          this.$message.success('改约规则修改成功')
          this.fetchData()
          this.handleClose()
        }
        this.saveLoading = false
      })
    },
    addRelation() {
      this.saveLoading = true
      addRelationRule(this.ruleFormSendData).then(res => {
        if (res && res.code === 10000) {
          this.$message.success(res.message)
          this.fetchData()
          this.handleClose()
        }
        this.saveLoading = false
      })
    },
    addExclude() {
      this.saveLoading = true
      addExcludeRule(this.ruleFormSendData).then(res => {
        if (res && res.code === 10000) {
          this.$message.success(res.message)
          this.fetchData()
          this.handleClose()
        }
        this.saveLoading = false
      })
    },
    addSequence() {
      this.saveLoading = true
      addSequenceRule(this.ruleFormSendData).then(res => {
        if (res && res.code === 10000) {
          this.$message.success(res.message)
          this.fetchData()
          this.handleClose()
        }
        this.saveLoading = false
      })
    },
    addPrior() {
      this.saveLoading = true
      addPriorRule(this.ruleFormSendData).then(res => {
        if (res && res.code === 10000) {
          this.$message.success(res.message)
          this.fetchData()
          this.handleClose()
        }
        this.saveLoading = false
      })
    },
    addMerge() {
      this.saveLoading = true
      addMergerule(this.ruleFormSendData).then(res => {
        if (res && res.code === 10000) {
          this.$message.success(res.message)
          this.fetchData()
          this.handleClose()
        }
        this.saveLoading = false
      })
    },
    addSplit() {
      this.saveLoading = true
      addSplitrule(this.ruleFormSendData).then(res => {
        if (res && res.code === 10000) {
          this.$message.success(res.message)
          this.fetchData()
          this.handleClose()
        }
        this.saveLoading = false
      })
    },
    addIntervalCondition() {
      this.saveLoading = true
      addtimeconditionrule(this.ruleFormSendData).then(res => {
        if (res && res.code === 10000) {
          this.$message.success(res.message)
          this.fetchData()
          this.handleClose()
        }
        this.saveLoading = false
      })
    },
    addProportionCondition() {
      this.saveLoading = true
      addnumberscale(this.ruleFormSendData).then(res => {
        if (res && res.code === 10000) {
          this.$message.success(res.message)
          this.fetchData()
          this.handleClose()
        }
        this.saveLoading = false
      })
    },
    handleEdit(formName) {
      this.$refs[formName].validate((valid, object) => {
        if (valid) {
          this.$confirm('是否确认修改该规则?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            try {
              this.getTypeApi(this.ruleForm.ruleType)
            } catch (error) {
              console.log('error', error)
            }
          }).catch(() => {})
        } else {
          for (let k in object) {
            this.$message.warning(object[k][0].message)
            return
          }
        }
      })
    },
    editTimeRule() {
      this.saveLoading = true
      this.ruleFormSendData.endtimeunit = this.ruleFormSendData.begintimeunit
      editTimeLimitRule(this.ruleFormSendData).then(res => {
        if (res && res.code === 10000) {
          this.$message.success(res.message)
          this.fetchData()
          this.handleClose()
        }
        this.saveLoading = false
      })
    },
    editInterval() {
      this.saveLoading = true
      editTimeIntervalRule(this.ruleFormSendData).then(res => {
        if (res && res.code === 10000) {
          this.$message.success(res.message)
          this.fetchData()
          this.handleClose()
        }
        this.saveLoading = false
      })
    },
    editgestationalweekrule() {
      this.saveLoading = true
      editgestationalweekrule(this.ruleFormSendData).then(res => {
        if (res && res.code === 10000) {
          this.$message.success(res.message)
          this.fetchData()
          this.handleClose()
        }
        this.saveLoading = false
      })
    },
    editRelation() {
      this.saveLoading = true
      editRelationRule(this.ruleFormSendData).then(res => {
        if (res && res.code === 10000) {
          this.$message.success(res.message)
          this.fetchData()
          this.handleClose()
        }
        this.saveLoading = false
      })
    },
    editExclude() {
      this.saveLoading = true
      editExcludeRule(this.ruleFormSendData).then(res => {
        if (res && res.code === 10000) {
          this.$message.success(res.message)
          this.fetchData()
          this.handleClose()
        }
        this.saveLoading = false
      })
    },
    editSequence() {
      this.saveLoading = true
      editSequenceRule(this.ruleFormSendData).then(res => {
        if (res && res.code === 10000) {
          this.$message.success(res.message)
          this.fetchData()
          this.handleClose()
        }
        this.saveLoading = false
      })
    },
    editPrior() {
      this.saveLoading = true
      editPriorRule(this.ruleFormSendData).then(res => {
        if (res && res.code === 10000) {
          this.$message.success(res.message)
          this.fetchData()
          this.handleClose()
        }
        this.saveLoading = false
      })
    },
    editMerge() {
      this.saveLoading = true
      editMergerule(this.ruleFormSendData).then(res => {
        if (res && res.code === 10000) {
          this.$message.success(res.message)
          this.fetchData()
          this.handleClose()
        }
        this.saveLoading = false
      })
    },
    editSplit() {
      this.saveLoading = true
      editSplitrule(this.ruleFormSendData).then(res => {
        if (res && res.code === 10000) {
          this.$message.success(res.message)
          this.fetchData()
          this.handleClose()
        }
        this.saveLoading = false
      })
    },
    editIntervalCondition() {
      this.saveLoading = true
      edittimeconditionrule(this.ruleFormSendData).then(res => {
        if (res && res.code === 10000) {
          this.$message.success(res.message)
          this.fetchData()
          this.handleClose()
        }
        this.saveLoading = false
      })
    },
    editProportionCondition() {
      this.saveLoading = true
      editnumberscalerule(this.ruleFormSendData).then(res => {
        if (res && res.code === 10000) {
          this.$message.success(res.message)
          this.fetchData()
          this.handleClose()
        }
        this.saveLoading = false
      })
    },
    fetchData() {
      this.$emit('refresh')
    },
    handleCheckChange(nodeData, checkedData) {
      if (this.ruleForm.ruleType === 8) { // 单选
      // 5：顺序规则，7：合并规则，8：拆分规则
        if (checkedData.checkedNodes.length > 0) {
          // 有勾选数据
          if (nodeData.level === 3) {
            this.$refs.tree.setCheckedNodes([nodeData])
            this.checkFlag = true
          } else if (nodeData.level === 2 && nodeData.childrens.length === 1) {
            this.$refs.tree.setCheckedNodes([nodeData])
            this.checkFlag = true
          } else if (nodeData.level === 1 && nodeData.childrens.length === 1 && nodeData.childrens[0].childrens.length === 1) {
            this.$refs.tree.setCheckedNodes([nodeData])
            this.checkFlag = true
          } else if (this.checkFlag &&
              ((nodeData.level === 2 && nodeData.childrens.length > 1) ||
              (nodeData.level === 1 && nodeData.childrens.length > 1) ||
              (nodeData.level === 1 && nodeData.childrens.length === 1 && nodeData.childrens[0].childrens.length > 1))) {
            this.$refs.tree.setCheckedNodes([])
            this.checkFlag = false
          } else {
            this.$refs.tree.setCheckedNodes([])
            this.checkFlag = false
            this.$message.warning('只能勾选一个检查项目')
          }
        } else {
          // 本身就是取消勾选
          this.checkFlag = false
        }
      }
      this.$nextTick(() => {
        this.getTreeCheckedData('tree', 'ruleTypes', 1)
      })
    },
    getTreeCheckedData(treeModel, storageRuleType, category) {
      let ruleCategory = this.checkCategory()
      // 如果一个父节点下面的子集都选择了，父级是全选的话，就提交一条数据，检查类型给数据，检查部位不用给了
      // 只有父级下面的自己部分选中的话，对应每个子集一条数据
      let checkedNodes = this.$refs[treeModel].getCheckedNodes()
      this.ruleForm2[storageRuleType] = []
      for (let i = 0; i < checkedNodes.length; i++) {
        // 5、顺序规则，7、合并规则，8、拆分规则
        // if (this.ruleForm.ruleType !== 5 && this.ruleForm.ruleType !== 7 && this.ruleForm.ruleType !== 8) {
        if (this.ruleForm.ruleType !== 8) {
          if (checkedNodes[i].level === 1) {
            this.ruleForm2[storageRuleType].push({ id: checkedNodes[i].id, ruleCategory: category || ruleCategory, dep: checkedNodes[i].text, dengjipart: null, checkpos: null })
          } else if (checkedNodes[i].level === 2) {
            // 判断父级有没有添加过
            let index = this.ruleForm2[storageRuleType].findIndex(item => item.id === checkedNodes[i].parentId)
            if (index === -1) {
              // 如果不存在，那么可以添加
              this.ruleForm2[storageRuleType].push({ id: checkedNodes[i].id, ruleCategory: category || ruleCategory, dep: checkedNodes[i].parentId, dengjipart: checkedNodes[i].text, checkpos: null })
            }
          } else if (checkedNodes[i].level === 3) {
            // 判断父级有没有添加过
            let index = this.ruleForm2[storageRuleType].findIndex(item => (item.id === checkedNodes[i].grandId || item.id === checkedNodes[i].grandId + checkedNodes[i].parentId + '2'))
            if (index === -1) {
              // 如果不存在，那么可以添加
              this.ruleForm2[storageRuleType].push({ id: checkedNodes[i].id, ruleCategory: category || ruleCategory, dep: checkedNodes[i].grandId, dengjipart: checkedNodes[i].parentId, checkpos: checkedNodes[i].text })
            }
          } else {
            console.log('深度不存在')
          }
        } else {
          // 拆分一定要是小部位
          if (checkedNodes[i].level === 3) {
            // 判断有没有添加过
            let index = this.ruleForm2[storageRuleType].findIndex(item => (item.id === checkedNodes[i].grandId || item.id === checkedNodes[i].grandId + checkedNodes[i].parentId + '2'))
            if (index === -1) {
              // 如果不存在，那么可以添加
              this.ruleForm2[storageRuleType].push({ id: checkedNodes[i].id, ruleCategory: category || ruleCategory, dep: checkedNodes[i].grandId, dengjipart: checkedNodes[i].parentId, checkpos: checkedNodes[i].text })
            }
          } else {
            console.log('深度不存在')
          }
        }
      }
    },
    handleOtherCheckChange(nodeData, checkedData) {
      if (this.ruleForm.ruleType === 8) { // 单选
      // 5：顺序规则，7：合并规则，8：拆分规则
        if (checkedData.checkedNodes.length > 0) {
          // 有勾选数据
          if (nodeData.level === 3) {
            this.$refs.treeOther.setCheckedNodes([nodeData])
            this.checkFlagOther = true
          } else if (nodeData.level === 2 && nodeData.childrens.length === 1) {
            this.$refs.treeOther.setCheckedNodes([nodeData])
            this.checkFlagOther = true
          } else if (nodeData.level === 1 && nodeData.childrens.length === 1 && nodeData.childrens[0].childrens.length === 1) {
            this.$refs.treeOther.setCheckedNodes([nodeData])
            this.checkFlagOther = true
          } else if (this.checkFlagOther && ((nodeData.level === 2 && nodeData.childrens.length > 1) || (nodeData.level === 1 && nodeData.childrens.length > 1) || (nodeData.level === 1 && nodeData.childrens.length === 1 && nodeData.childrens[0].childrens.length > 1))) {
            this.$refs.treeOther.setCheckedNodes([])
            this.checkFlagOther = false
          } else {
            this.$refs.treeOther.setCheckedNodes([])
            this.checkFlagOther = false
            this.$message.warning('只能勾选一个检查项目')
          }
        } else {
          // 本身就是取消勾选
          this.checkFlagOther = false
        }
      }
      this.$nextTick(() => {
        this.getTreeCheckedData('treeOther', 'ruleOtherTypes')
      })
    },
    handleOtherCheckChange2(nodeData, checkedData) {
      if (this.ruleForm.ruleType === 8) { // 单选
      // 5：顺序规则，7：合并规则，8：拆分规则
        if (checkedData.checkedNodes.length > 0) {
          // 有勾选数据
          if (nodeData.level === 3) {
            this.$refs.treeOther2.setCheckedNodes([nodeData])
            this.checkFlagOther2 = true
          } else if (nodeData.level === 2 && nodeData.childrens.length === 1) {
            this.$refs.treeOther2.setCheckedNodes([nodeData])
            this.checkFlagOther2 = true
          } else if (nodeData.level === 1 && nodeData.childrens.length === 1 && nodeData.childrens[0].childrens.length === 1) {
            this.$refs.treeOther2.setCheckedNodes([nodeData])
            this.checkFlagOther2 = true
          } else if (this.checkFlagOther2 && ((nodeData.level === 2 && nodeData.childrens.length > 1) || (nodeData.level === 1 && nodeData.childrens.length > 1) || (nodeData.level === 1 && nodeData.childrens.length === 1 && nodeData.childrens[0].childrens.length > 1))) {
            this.$refs.treeOther2.setCheckedNodes([])
            this.checkFlagOther2 = false
          } else {
            this.$refs.treeOther2.setCheckedNodes([])
            this.checkFlagOther2 = false
            this.$message.warning('只能勾选一个检查项目')
          }
        } else {
          // 本身就是取消勾选
          this.checkFlagOther2 = false
        }
      }
      this.$nextTick(() => {
        this.getTreeCheckedData('treeOther2', 'ruleOtherTypes2')
      })
    },
    // 判断规则的检查类型
    checkCategory() {
      let ruleCategory = 0
      // 1检查类型；3前置检查类型；4排斥检查类型；5顺序检查类型）
      switch (this.ruleForm.ruleType) {
        case 1:
          ruleCategory = 1
          break
        case 2:
          ruleCategory = 1
          break
        case 3:
          ruleCategory = 3
          break
        case 4:
          ruleCategory = 4
          break
        case 5:
          ruleCategory = 5
          break
        case 6:
          ruleCategory = 1
          break
        case 7:
          ruleCategory = 7
          break
        case 8:
          ruleCategory = 8
          break
        default:
          break
      }
      return ruleCategory
    },
    // 进行默认勾选
    checkTreeRow() {
      let checkTypeNodes = []
      let checkTypeOtherNodes = []
      let checkTypeOtherNodes2 = []
      if (this.ruleForm2.ruleTypes.length !== 0) {
        for (let i = 0; i < this.ruleForm2.ruleTypes.length; i++) {
          let obj = this.ruleForm2.ruleTypes[i]
          if (!this.ruleForm2.ruleTypes[i].dengjipart) {
            // level1
            checkTypeNodes.push(Object.assign(obj, { id: this.ruleForm2.ruleTypes[i].dep }))
          } else if (!this.ruleForm2.ruleTypes[i].checkpos) {
            // level2
            checkTypeNodes.push(Object.assign(obj, { id: this.ruleForm2.ruleTypes[i].dep + this.ruleForm2.ruleTypes[i].dengjipart + '2' }))
          } else {
            // level3
            checkTypeNodes.push(Object.assign(obj, { id: this.ruleForm2.ruleTypes[i].dep + this.ruleForm2.ruleTypes[i].dengjipart + '2' + this.ruleForm2.ruleTypes[i].checkpos + '3' }))
          }
        }
      }
      if (this.ruleForm2.ruleOtherTypes.length !== 0) {
        for (let i = 0; i < this.ruleForm2.ruleOtherTypes.length; i++) {
          let obj = this.ruleForm2.ruleOtherTypes[i]
          if (!this.ruleForm2.ruleOtherTypes[i].dengjipart) {
            // level1
            checkTypeOtherNodes.push(Object.assign(obj, { id: this.ruleForm2.ruleOtherTypes[i].dep }))
          } else if (!this.ruleForm2.ruleOtherTypes[i].checkpos) {
            // level2
            checkTypeOtherNodes.push(Object.assign(obj, { id: this.ruleForm2.ruleOtherTypes[i].dep + this.ruleForm2.ruleOtherTypes[i].dengjipart + '2' }))
          } else {
            // level3
            checkTypeOtherNodes.push(Object.assign(obj, { id: this.ruleForm2.ruleOtherTypes[i].dep + this.ruleForm2.ruleOtherTypes[i].dengjipart + '2' + this.ruleForm2.ruleOtherTypes[i].checkpos + '3' }))
          }
        }
      }
      if (this.ruleForm2.ruleOtherTypes2.length !== 0) {
        for (let i = 0; i < this.ruleForm2.ruleOtherTypes2.length; i++) {
          let obj = this.ruleForm2.ruleOtherTypes2[i]
          if (!this.ruleForm2.ruleOtherTypes2[i].dengjipart) {
            // level1
            checkTypeOtherNodes2.push(Object.assign(obj, { id: this.ruleForm2.ruleOtherTypes2[i].dep }))
          } else if (!this.ruleForm2.ruleOtherTypes2[i].checkpos) {
            // level2
            checkTypeOtherNodes2.push(Object.assign(obj, { id: this.ruleForm2.ruleOtherTypes2[i].dep + this.ruleForm2.ruleOtherTypes2[i].dengjipart + '2' }))
          } else {
            // level3
            checkTypeOtherNodes2.push(Object.assign(obj, { id: this.ruleForm2.ruleOtherTypes2[i].dep + this.ruleForm2.ruleOtherTypes2[i].dengjipart + '2' + this.ruleForm2.ruleOtherTypes2[i].checkpos + '3' }))
          }
        }
      }
      this.ruleForm2.ruleTypes = checkTypeNodes
      this.ruleForm2.ruleOtherTypes = checkTypeOtherNodes
      this.ruleForm2.ruleOtherTypes2 = checkTypeOtherNodes2
      this.$nextTick(() => {
        setTimeout(() => {
          this.$refs.tree && this.$refs.tree.setCheckedNodes(checkTypeNodes)
          this.$refs.treeOther && this.$refs.treeOther.setCheckedNodes(checkTypeOtherNodes)
          this.$refs.treeOther2 && this.$refs.treeOther2.setCheckedNodes(checkTypeOtherNodes2)
          this.$nextTick(() => {
            // 原数据更新赋值
            this.$refs.tree && this.getTreeCheckedData('tree', 'ruleTypes', 1)
            this.$refs.treeOther && this.getTreeCheckedData('treeOther', 'ruleOtherTypes')
            this.$refs.treeOther2 && this.getTreeCheckedData('treeOther2', 'ruleOtherTypes2')
          })
        }, 200)
      })
    },
    // 删除规则组，规则组内容清空后回调
    delGroup(groupIndex) {
      const ruleGroupData = this.getGroupAllData()
      ruleGroupData.splice(groupIndex, 1)
      this.ruleConts = JSON.parse(JSON.stringify(ruleGroupData))
    },
    // 复制规则组
    copyGroup(groupIndex) {
      const contData = this.$refs[`'${'ruleItemBox_' + groupIndex}'`] && this.$refs[`'${'ruleItemBox_' + groupIndex}'`][0].getRuleData()
      this.ruleConts.push(JSON.parse(JSON.stringify(contData)))
    },
    // 添加场景条件组
    addConditionGround() {
      this.ruleConts.push([...defaultRule])
    },
    // 获取所有组数据
    getGroupAllData() {
      const ruleGroupData = []
      this.ruleConts.forEach((item, index) => {
        const contData = this.$refs[`'${'ruleItemBox_' + index}'`] && this.$refs[`'${'ruleItemBox_' + index}'`][0].getRuleData()
        ruleGroupData.push(contData)
      })
      return ruleGroupData
    },
    initRuleContents(data) {
      const rules = {}
      data.forEach(item => {
        const _k = !item.ruleContentGroup && item.ruleContentGroup !== 0 ? 'ro' : item.ruleContentGroup
        if (rules[_k]) {
          rules[_k].push(item)
        } else {
          rules[_k] = [{ ...item }]
        }
      })
      return Object.keys(rules).map(r => rules[r])
    },
    changeRuleType(val) {
      this.ruleForm2 = {}
      this.$refs.tree && this.$refs.tree.setCheckedKeys([])
      this.$refs.treeOther && this.$refs.treeOther.setCheckedKeys([])
      this.$refs.treeOther2 && this.$refs.treeOther2.setCheckedKeys([])
      let ruleForm = {
        ruleTypes: [],
        ruleOtherTypes: [],
        ruleOtherTypes2: [],
        priority: 0,
        begintime: null,
        begintimeunit: 1,
        endtimeunit: 1,
        endtime: null,
        ruleContents: []
      }
      if (val === 11) {
        // 孕周规则，设置默认规则类型，目前只在乐清三医项目使用
        ruleForm.ruleContents = [...yzRule]
        this.ruleConts = [[...yzRule]]
      }
      this.activeName = 'first'
      this.ruleForm = Object.assign(this.ruleForm, ruleForm)
      this.clearFilter()
      this.checkFlag = false
      this.checkFlagOther = false
      this.checkFlagOther2 = false
      this.setRuleConditionGroup()
    },
    filterNode(value, data, node) {
      return this.filterNodeComm('filterIds', 'checkTypeSelectFilter', value, data, node)
    },
    filterOtherNode(value, data, node) {
      return this.filterNodeComm('filterOtherIds', 'checkTypeSelectFilterOther', value, data, node)
    },
    filterOtherNode2(value, data, node) {
      return this.filterNodeComm('filterOtherIds2', 'checkTypeSelectFilterOther2', value, data, node)
    },
    // 检查类型过滤，公用函数
    filterNodeComm(idsKey, stFilter, value, data, node) {
      if ((this[`${idsKey}`].length == 0 && !value) || (typeof value === 'object' && value.length === 0)) {
        node.expanded = false
        return true
      }
      if (typeof value === 'string') {
        let flag = false
        // 判断文字查询是否指定字段
        if (this[`${stFilter}`] && this[`${stFilter}`] * 1 === 2) {
          if (data.level === 3) {
            if (this[`${idsKey}`].length === 0 || this[`${idsKey}`].length > 0 && this[`${idsKey}`].indexOf(data.grandId) > -1) {
              if (data.parentId.indexOf(value) !== -1) {
                return true
              } else {
                return false
              }
            } else {
              return false
            }
          }
        }
        if (this[`${stFilter}`] && this[`${stFilter}`] * 1 === 3 && data.level === 2) {
          return false
        }

        if (this[`${idsKey}`].length === 0 && data.text.indexOf(value) !== -1) {
          flag = true
        } else if (this[`${idsKey}`].length > 0 && (this[`${idsKey}`].indexOf(data.parentId) > -1 || this[`${idsKey}`].indexOf(data.grandId) > -1) && data.text.indexOf(value) !== -1) {
          flag = true
        }
        return flag
      } else if (typeof value === 'object') {
        let flag = false
        for (let v of value) {
          if (v === data.text || this[`${idsKey}`].indexOf(data.parentId) > -1 || this[`${idsKey}`].indexOf(data.grandId) > -1) {
            flag = true
            this[`${idsKey}`].push(data.id)
          }
        }
        return flag
      }
    },
    clearFilter() {
      this.checkType = []
      this.checkOtherType = []
      this.checkOtherType2 = []
      this.filterText = ''
      this.filterTextOther = ''
      this.filterTextOther2 = ''
      this.filterIds = []
      this.filterOtherIds = []
      this.filterOtherIds2 = []
    },
    getHisTree() {
      return new Promise((rs, rj) => {
        getHisDepTree({ HospitalCode: this.hospitalCode }).then(res => {
          this.checkTypeData = []
          this.checkOtherTypeData = []
          this.checkOtherTypeData2 = []
          if (res && res.code === 10000) {
            let depNodes = res.content.childrens
            // this.trackIndex = []
            // this.formatHisTree(this.checkTypeData)
            for (let i = 0; i < depNodes.length; i++) {
              let tempLevel1 = { text: depNodes[i].text, level: 1, childrens: [], id: depNodes[i].text }
              // 如果存在部位
              if (depNodes[i].childrens && depNodes[i].childrens.length !== 0) {
                for (let j = 0; j < depNodes[i].childrens.length; j++) {
                  let level1Children = depNodes[i].childrens
                  // 加上level防止同名
                  let tempLevel2 = { text: level1Children[j].text, level: 2, childrens: [], id: tempLevel1.id + level1Children[j].text + level1Children[j].level, parentId: tempLevel1.text }
                  if (level1Children[j].childrens && level1Children[j].childrens.length !== 0) {
                    tempLevel2.childrens = level1Children[j].childrens.map(item => {
                      return { text: item.text, level: 3, childrens: [], id: tempLevel2.id + item.text + item.level, parentId: tempLevel2.text, grandId: tempLevel2.parentId }
                    })
                  }
                  tempLevel1.childrens.push(tempLevel2)
                }
              }
              this.checkTypeData.push(tempLevel1)
            }
            this.checkOtherTypeData = [...this.checkTypeData]
            this.checkOtherTypeData2 = [...this.checkTypeData]
            rs()
          } else {
            rj()
          }
        }).catch(() => {
          rj()
        })
      })
    },
    async rowClick(row, column, event) {
      let formTemp = { ...row }
      let otherTypeTemp = []
      let otherTypeTemp2 = []
      let typeTemp = []
      let data = {
        hospitalCode: this.ruleForm.hospitalCode,
        RuleInfoId: row.id
      }
      this.saveLoading = true
      getAppointmentRuleContentList(data).then(res => {
        if (!res) return
        formTemp.ruleContents = res.content.list
        this.ruleForm = formTemp
        for (let i = 0; i < formTemp.ruleContents.length; i++) {
          // 获取content对应的控件和控件里应有分字段值
          let obj = this.ruleConditionOptions.find(item => {
            return item.dicEname === formTemp.ruleContents[i].ruleCondition &&
             item.controllType === formTemp.ruleContents[i].controllType &&
             item.modelType === formTemp.ruleContents[i].modelType
          })
          // console.log('rowClick', obj)
          if (obj) {
            formTemp.ruleContents[i].ruleConditionId = obj.id
          }
        }
        const initRules = this.initRuleContents(formTemp.ruleContents)
        this.ruleConts = initRules.length ? initRules : [[...defaultRule]]

        this.setRuleConditionGroup()
      })
      // 获取类型合并跟根据 type分开， 存在ruleform的ruleTypes 和  ruleOtherTypes 中
      await getRuleTypeList(data).then(res => {
        if (res && res.code === 10000) {
          let Res = res.content.list
          for (let i = 0; i < Res.length; i++) {
            if (Res[i].ruleCategory === 1) {
              // 放在 ruleTypes 给tree打勾
              typeTemp.push(Res[i])
            } else {
              // 其它类型 放在ruleOtherTypes 给 treeOther 打勾
              if (Res[i].ruleCategory === 8 && otherTypeTemp.length > 0) { // 拆分规则有第三棵树，每棵树一条数据
                otherTypeTemp2.push(Res[i])
              } else {
                otherTypeTemp.push(Res[i])
              }
            }
          }
          this.ruleForm2.ruleTypes = typeTemp
          this.ruleForm2.ruleOtherTypes = otherTypeTemp
          this.ruleForm2.ruleOtherTypes2 = otherTypeTemp2
          if (this.curStatus === this.pageStatus.edit) {
            // 当前是编辑状态（右边有form）
            // 进行勾选
            this.checkTreeRow()
          }
        }
      })
      this.saveLoading = false
    },
    // 新增规则，使用默认设置的规则选项
    rowDefault(data) {
      const temp = JSON.parse(JSON.stringify(this.ruleForm))
      temp.id = ''
      temp.ruleContents = [...data.ruleContents]
      temp.ruleType = data.ruleType
      this.ruleForm = { ...temp }
      this.ruleConts = data.ruleContents ? [[...data.ruleContents]] : [[...defaultRule]]
      console.log('ruleConts=-=-=-=', this.ruleConts)
      this.setRuleConditionGroup()
    },
    changeBatch(val) {
      this.ruleForm.status = val
    },
    getItemList() {
      return new Promise((rs, rj) => {
        this.ruleConditionOptions = []
        getItemDicList({ hospitalCode: this.hospitalCode }).then(async res => {
          if (res && res.code === 10000) {
            this.ruleConditionOptions = res.content.list
            await this.setRuleConditionGroup()
            this.$forceUpdate()
            rs()
          } else {
            rj()
          }
        }).catch(() => {
          rj()
        })
      })
    },
    // 计算检查规则选项、检查规则提示说明
    setRuleConditionGroup() {
      return new Promise(resolve => {
        const gOptions = []
        const ruleExplainRule = []
        this.options.modelTypeOptions.forEach(item => {
          /**
             *      { value: 3, label: '预约申请单' },
             *      { value: 1, label: '预约号源时段' },
             *      { value: 2, label: '预约时段限制条件' },
             *      { value: 4, label: '预约号源比例' }
             *      { value: 5, label: '申请单限制条件' }
             *  */
          if (item.value === 1 && [1, 2, 6, 9, 10, 11].includes(this.ruleForm.ruleType)) {
            gOptions.push({
              ...item,
              options: []
            })
          } else if (item.value === 2 && [1, 2, 6, 11].includes(this.ruleForm.ruleType)) {
            gOptions.push({
              ...item,
              options: []
            })
          } else if (item.value === 3 || item.value === 5) {
            gOptions.push({
              ...item,
              options: []
            })
          } else if (item.value === 4 && [10].includes(this.ruleForm.ruleType)) {
            gOptions.push({
              ...item,
              options: []
            })
          }
        })
        // 选项分组
        this.ruleConditionOptions.forEach(item => {
          const idx = gOptions.findIndex(opt => opt.value === item.modelType)
          if (idx >= 0) {
            gOptions[idx].options.push(item)
          }
        })

        // 过滤掉没有选项的项
        gOptions.forEach((item, index) => {
          if (item.options.length === 0) {
            gOptions.splice(index, 1)
          } else {
            ruleExplainRule.push(item.label.replace('预约', ''))
          }
        })
        this.ruleConditionGroupOptions = gOptions
        this.ruleExplain = `说明：检查规则，按${ruleExplainRule.join('、')}规则匹配可预约时段，规则组之间条件判断为或关系`
        // console.log('this.ruleConditionOptions', this.ruleConditionOptions)
        // console.log('this.ruleConditionGroupOptions', this.ruleConditionGroupOptions)
        if (this.ruleForm.ruleType === 9) {
          this.ruleExplain += '（申请单和号源时段必填）'
        }
        resolve()
      })
    },
    getCheckTypeTreeOptions() {
      /* 检查部门列表 */
      let params = {
        hospitalCode: this.hospitalCode,
        depArea: ''
      }
      return new Promise(async resolve => {
        await getDepList(params).then((res) => {
          if (res.code === 10000) {
            this.checkTypeTreeOptions = res.content.list
            resolve(res)
          }
        })
      })
    },
    $_resizeHandler() {
      const rect = body.getBoundingClientRect()
      this.dlgWidth = rect.width > 1288 ? rect.width < 1588 ? '80%' : '70%' : '100%'
    }
  },
  beforeMount() {
    window.addEventListener('resize', this.$_resizeHandler)
  },
  beforeDestroy() {
    window.removeEventListener('resize', this.$_resizeHandler)
  },
  destroyed() {},
  beforeUpdate() {},
  updated() {}
}
</script>
<style lang='scss' scoped>
.temp_tit{
  font-size: 16px;
  padding: 15px 20px;
  line-height: 18px;
}
.rule_wrap{
  border-left: 1px solid #e5e5e5;
  padding: 0px 24px 37px;
  color: #606266;
  // width:640px;
  background-color: #FFFFFF;
  // float:right;
  display: flex;
  .rule_basebox{
    width: 600px;
    padding-right: 10px;
  }
  .rule_checkpartbox{
    flex: 1;
  }

  /deep/ .el-form-item{
      margin-bottom: 10px;
  }
  .short-input{
    display: inline-block;
    width: 270px;
    // /deep/ .el-input{
    //     width: 200px;
    // }
  }
  // .small-text{
  //     margin-bottom: 5px;
  // }
  .describe-input{
      width: 590px;
      .el-input{
          width: 490px;
      }
  }
  .name{
      font-weight: bold;
  }
  .el-form--inline .el-form-item{
      margin-right:0px
  }
  .change-box{
      padding: 12px 16px 16px 16px;
      background: #F3F6FB;
      border-radius: 4px;
      margin-bottom: 10px;
      .rule_box_title{
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 2px 0x;
        line-height: 40px;
        .tit{
          font-weight: bold;
          font-size: 12px;
        }
      }
      .rule_type_title{
        display: flex;
        align-items: center;
        padding: 2px 0 2px 10px;
        line-height: 20px;
        .tit{
          // font-weight: bold;
          min-width: 74px;
          color: #666;
          font-size: 12px;
        }
      }
      .check-input{
          margin-right: 16px;
          /deep/ .el-form-item__label{
              font-size: 12px;
          }
          /deep/ .el-input__inner{
              width:140px;
          }
          /deep/ .el-input__inner{
              width:140px;
          }
      }
      .el-form-item{
          margin-bottom: 10px;
          /deep/ .el-input__inner{
            // height: 28px!important;
            height: inherit;
            line-height: 28px;
            font-size: 12px;
          }
          /deep/ .el-input__suffix{
              top: 0px;
          }
      }
      .check_type_search{
        /deep/ .check_select .el-input__inner{
            width:180px;
        }
        /deep/ .check_ipt .el-input__inner{
            width:130px;
        }
        .ipt_apend /deep/ .el-input__inner{
            width:80px;
            padding-left: 10px;
        }
        /deep/ .el-form-item__content{
          line-height: 30px;
        }
        /deep/ .el-input__icon{
          line-height: 30px;
        }
      }
  }
  .small-font{
      font-size: 12px;
      /deep/ .el-form-item__label{
          font-size: 12px;
      }
      span{
          font-size: 12px;
      }
  }
  .small-tag{
      /deep/ .el-select__tags{
          .el-tag:first-child{
              max-width: 105px;
              padding-right: 15px;
              overflow: hidden;
              position: relative;
              text-overflow: ellipsis;
              .el-tag__close{
                  position: absolute;
                  right: 0;
                  top: 3px;
              }
          }
          .el-select__input{
              margin-left: 10px;
          }
      }
  }
  .m-b-1{
      .m-b-1-width{
          /deep/ .el-input__inner{
              width:165px;
          }
      }
      .m-b-1-width-small{
          /deep/ .el-input__inner{
              width:100px;
          }
      }
      .m-b-1-width-big{
          /deep/ .el-input__inner{
              width:210px;
          }
      }
      .m-b-1-margin{
          margin-right: 11px;
      }
      .el-icon-error{
          cursor: pointer;
      }
  }
  .m-b-0{
      /deep/ .el-form-item__content{
          width: 100%;
      }
      .m-b-1:hover{
          .hover-show{
              display: inline-block;
          }
      }
      .hover-show{
          display:none
      }
  }
}
.tree{
  // max-height: 720px;
  overflow-x: auto;
  width: 100%;
  /deep/ .el-form-item__content{
      display: block;
      // height: 720px;
      .el-tree{
          height:100%;
          .el-tree-node{
              background-color: #fff;
          }
      }
  }
}
.buttons{
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: #fff;
    padding: 5px 25px;
    border-top: 1px solid #E5E7EC;
    line-height: 31px;
    z-index: 1;
    /deep/ .el-form-item__content{
        width:100%
    }
    .rule_explain_btn{
      float:left;
      cursor: default;
    }
    .right-buttons{
        float:right
    }
    .el-dropdown{
        color: #00c0ef;
    }
}
.el-input{
  width:auto;
  .el-input__suffix-inner span{
    color: #606266;
  }
}
.rule_styles{
  display: flex;
  font-size: 12px;
  color: #666;
  align-items: center;
  justify-content: space-between;
  .rule_style_item{
    margin-left: 10px;
  }
}
.form-a{
  cursor: pointer;
  color: #00C0EF;
}
.el-form {
  .el-select--small{
    /deep/ .el-input__icon{
        line-height: 40px;
    }
  }
}
.timeType{
  /deep/ .el-input__inner{
    margin-left: 5px;
    width: 140px;
  }
}
.rule_cont_group{
  padding: 3px;
  margin-bottom: 10px;
  border: dashed 1px #999;
  border-radius: 4px;
}
.rule_group_tips{
  font-size: 12px;
  color: #f00;
  line-height: 1.8em;
}
</style>
